import { Injectable } from '@nestjs/common'
import { InjectRepository } from '@nestjs/typeorm'
import { Repository } from 'typeorm'
import { CreateUserDTO } from './dto/create-user.dto'
import { User } from './entities/user.entity'

@Injectable()
export class UserService {
  constructor(
    @InjectRepository(User)
    private readonly userRepo: Repository<User>
  ) {}

  create(user: CreateUserDTO) {
    return this.userRepo.insert(user)
  }

  list() {
    return this.userRepo.find()
  }

  delete(id: string) {
    return this.userRepo.delete(id)
  }
}
